Skip to content

fix: drop nulls in mapNotNull instead of padding with zeros (#355) - #367

Merged
devcrocod merged 1 commit into
developfrom
fix/map-not-null-drops-nulls
Nov 12, 2026
Merged

devcrocod merged 1 commit into
developfrom
fix/map-not-null-drops-nulls

Conversation

@devcrocod

Copy link
Copy Markdown
Collaborator

mapNotNull, mapIndexedNotNull and mapMultiIndexedNotNull return only the non-null results instead of padding the tail with zeros. The result is 1D, as with filter, so mapNotNull and mapMultiIndexedNotNull now return D1Array<R> instead of NDArray<R, D> (source-incompatible for D > 1).

Fixes #355

Testing

  • IterableNDArrayTest and doc samples on JVM and macosArm64; new tests on JS (node)
  • apiCheck korroCheck

Checklist

  • Existing tests pass
  • New/updated tests for changed behavior
  • New/updated documentation if necessary

mapNotNull, mapIndexedNotNull and mapMultiIndexedNotNull return a 1D array
of the non-null results. mapNotNull and mapMultiIndexedNotNull now return
D1Array<R> instead of NDArray<R, D>, as filter does.
Copilot AI balanced review requested due to automatic review settings November 12, 2026 14:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The D1Array return-type changes break source compatibility for higher-dimensional callers and conflict with repository guidance, requiring maintainer confirmation of the compatibility exception and migration/release handling.

No open issues 🎉

What changed in this PR

Fixes #355 by making the three NotNull mapping operations drop null results instead of padding with zeros. Results are always 1D, matching filter; this changes the return type of mapNotNull and mapMultiIndexedNotNull and is source-incompatible for callers expecting higher-dimensional results.

Changes:

  • Trims result storage to the non-null count and returns D1Array<R>.
  • Adds regression tests for filtering, empty results, traversal order, and result types.
  • Updates KDoc, API documentation, and synchronized examples.
File Description
multik-core/​src/​commonTest/​kotlin/​samples/​docs/​apiDocs/​arrayOperations.kt Adds a null-dropping mapping example.
multik-core/​src/​commonTest/​kotlin/​org/​jetbrains/​kotlinx/​multik/​iterable/​IterableNDArrayTest.kt Adds regression coverage for all three operations.
multik-core/​src/​commonMain/​kotlin/​org/​jetbrains/​kotlinx/​multik/​ndarray/​operations/​IteratingNDArray.kt Compacts results, standardizes 1D output, and documents behavior.
docs/​topics/​gettingStarted/​quickstart.md Adds the mapMultiIndexedNotNull reference link.
docs/​topics/​apiDocs/​map.md Updates signatures, return semantics, and examples.

Review effort: Balanced

@devcrocod
devcrocod merged commit c515f43 into develop Nov 12, 2026
3 checks passed
@devcrocod
devcrocod deleted the fix/map-not-null-drops-nulls branch November 12, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mapNotNull pads the result with zeros instead of dropping nulls

2 participants